package com.yizhilu.os.edu.servlet;

import java.util.Date;

/**
 * 
 * @author Administrator
 *
 */
public class FormatXmlProcess {
	/**
	 * 封装文字类的返回消息
	 * @param to
	 * @param from
	 * @param content
	 * @return
	 */
	public String formatXmlAnswer(String to, String from, String content) {
		StringBuffer sb = new StringBuffer();
		Date date = new Date();
		sb.append("<xml><ToUserName><![CDATA[");
		sb.append(to);
		sb.append("]]></ToUserName><FromUserName><![CDATA[");
		sb.append(from);
		sb.append("]]></FromUserName><CreateTime>");
		sb.append(date.getTime());
		sb.append("</CreateTime><MsgType><![CDATA[text]]></MsgType><Content><![CDATA[");
		sb.append(content);
		sb.append("]]></Content><FuncFlag>0</FuncFlag></xml>");
		return sb.toString();
	}
	
	
	/**
	 * 封装图文类的返回消息
	 * @param to
	 * @param from
	 * @param content
	 * @return
	 */
	public String formatXmlNewsAnswer(String to, String from, String Url,String imgUrl,String desc,String title) {
		StringBuffer sb = new StringBuffer();
		Date date = new Date();
	    sb.append("<xml>");
		sb.append("<ToUserName><![CDATA["+to+"]]></ToUserName>");
		sb.append("<FromUserName><![CDATA["+from+"]]></FromUserName>");
		sb.append("<CreateTime>");
		sb.append(date.getTime());
		sb.append("</CreateTime><MsgType><![CDATA[news]]></MsgType>");
		sb.append("<ArticleCount>1</ArticleCount>");
		sb.append("<Articles>  ");
		sb.append("<item>");
		sb.append("<Title><![CDATA["+title+"]]></Title> ");
		sb.append("<Description><![CDATA["+desc+"]]></Description>");
		sb.append("<PicUrl><![CDATA["+imgUrl+"]]></PicUrl>");
		sb.append("<Url><![CDATA["+Url+"]]></Url>  ");
		sb.append("</item>");		
		sb.append("</Articles>");
		sb.append("<FuncFlag>1</FuncFlag>");
		sb.append("</xml>");		 
		return sb.toString();
	}
}
